//
//  MOAddressBookViewCell.m
//  MobileOffice
//
//  Created by 冰冰 on 2019/6/9.
//  Copyright © 2019 com.idolmedia. All rights reserved.
//

#import "MOAddressBookViewCell.h"

@interface MOAddressBookViewCell ()

@property(nonatomic,strong)UIImageView *iconImageView;

@property(nonatomic,strong)UILabel *nameLabel;

//分割线
@property(nonatomic,strong)UIView *oneLine;

@property(nonatomic,strong)UIView *twoLine;

@property(nonatomic,strong)UIView *threeLine;

@end

@implementation MOAddressBookViewCell

+(instancetype)cellWithTableView:(UITableView *)tableView andIndexPath:(NSIndexPath *)indexPath
{
    //NSString *ID = [NSString stringWithFormat:@"Cell%ld%ld",(long)[indexPath section],(long)[indexPath row]];
    NSString *ID = @"MOAddressBookViewCell";
    MOAddressBookViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (cell == nil){
        cell = [[MOAddressBookViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        [cell creatView];
    }
    return cell;
}


-(void)creatView
{
    [self addSubview:self.iconImageView];
    [self addSubview:self.nameLabel];
    [self addSubview:self.oneLine];
    [self addSubview:self.twoLine];
    [self addSubview:self.threeLine];
}


-(void)setModel:(MOAddressBookModel *)model
{
    self.nameLabel.text = model.nameStr;
    if (model.cellIndex==model.allCount-1) {
        self.oneLine.height = 64/2;
    }else{
        self.oneLine.height = 64;
    }
}

#pragma mark -- 懒加载
-(UIImageView *)iconImageView
{
    if (!_iconImageView) {
        _iconImageView = [[UIImageView alloc]initWithFrame:CGRectMake(61, 0, 6, 6)];
        _iconImageView.centerY = 64/2;
        _iconImageView.image = IMAGE(@"address_juxing");
    }
    return _iconImageView;
}

-(UILabel *)nameLabel
{
    if (!_nameLabel) {
        _nameLabel = [[UILabel alloc]initWithFrame:CGRectMake(_iconImageView.right + 3, 0, SCREEN_WIDTH - 130, 20)];
        _nameLabel.textColor = KBlackColor_2A2A2A;
        _nameLabel.font = FONT_SIZE(16);
        _nameLabel.centerY = 64/2;
    }
    return _nameLabel;
}

-(UIView *)oneLine
{
    if (!_oneLine) {
        _oneLine = [[UIView alloc]initWithFrame:CGRectMake(37, 0, 1, 64)];
        _oneLine.backgroundColor = KGrayColor_ededed;
    }
    return _oneLine;
}

-(UIView *)twoLine
{
    if (!_twoLine) {
        _twoLine = [[UIView alloc]initWithFrame:CGRectMake(38, 0, 23, 1)];
        _twoLine.backgroundColor = KGrayColor_ededed;
        _twoLine.centerY = 64/2;
    }
    return _twoLine;
}


-(UIView *)threeLine
{
    if (!_threeLine) {
        _threeLine = [[UIView alloc]initWithFrame:CGRectMake(72, 63, SCREEN_WIDTH-63, 1)];
        _threeLine.backgroundColor = KGrayColor_ededed;
    }
    return _threeLine;
}

@end
